# -*- coding: utf-8 -*-

from flask import Flask, jsonify
from flasgger import Swagger,swag_from

app = Flask(__name__)
app.config['SWAGGER'] = {
    'title': u"API插件平台",
    'uiversion': 2,
    'description': u"Powered by 新境界-AI团队",
    'version': "1.0.0.0"
}

template = {
  "swagger": "2.0",
    "tags":[
        {
            "name": "users",
            "description": "sdf"
        }
    ]
}


swagger = Swagger(app,template=template)

specs_dict1 = {
  "summary": "fsdf",
  "description": "ffff333",
  "tags": ["users"],
  "externalDocs" :{
    "description": "Project repository",
    "url": "http://github.com/rochacbruno/flasgger"
  },
    "parameters": [
        {
            "name": "body",
            "in": "body",
            "required": "true",
            "schema": {
                "id": "UserInfo",
                "required": ["UserID"],
                "type": "object",
                "properties": {
                    "UserID": {
                        "type": "string",
                        "description": "用户ID"
                    },
                    "UserName": {
                        "type": "string",
                        "description": "用户姓名"
                    },
                    "UserDept": {
                        "schema": {
                            "id": "UserDept",
                            "required": ["userDept"],
                            "type": "object",
                            "properties": {
                                "userDept": {
                                    "type": "string",
                                    "description": "df"
                                }
                            }
                        }
                    }
                }
            }
        }
    ],
  "definitions": {
    "Palette": {
      "type": "object",
      "xml": {
          "name": "测试"
      },
      "properties": {
        "palette_name": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Color"
          }
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "A list of colors (may be filtered by palette)",
      "schema": {
        "$ref": "#/definitions/Palette"
      },
      "examples": {
        "rgb": [
          "red",
          "green",
          "blue"
        ]
      }
    }
  }
}

@app.route('/colors1/<palette>/', methods=["GET","POST"])
@swag_from(specs_dict1,validation=True)
def colors(palette):
    return ""

#a = swag_from(specs_dict1,validation=True)
#a(colors)


app.run(debug=True)